﻿using System;
using System.Collections.Generic;
using System.Text;

namespace task4
{
    class Matrix
    {
        static void Main(string[] arg)
        {
            int[,] matrix = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 10, 11, 12, 13 }, { 14, 15, 16, 17 } };

            if (IsToeplitz(matrix) == true)
            {
                Console.WriteLine("是托普利茨矩阵");

            }
            else
            {
                Console.WriteLine("不是托普利茨矩阵");
            }

        }


        private static bool IsToeplitz(int[,] matrix)
        {
            for (int i = 0; i < matrix.GetLength(0) - 1; i++)
            {
                for (int j = 0; j < matrix.GetLength(1) - 1; j++)
                {
                    if (matrix[i + 1, j + 1] != matrix[i, j])
                    {
                        return false;
                    }
                }
            }

            return true;

        }
    }
}
